package com.open.harmony.controller;


import com.open.harmony.business.entity.User;
import com.open.harmony.business.service.UserService;
import com.open.harmony.business.service.serviceImpl.UserServiceImpl;
import com.open.harmony.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserServiceImpl userService) {
        this.userService = userService;
    }

    @GetMapping("/login")
    public Result login(String userAccount, String userPassword){
        return userService.login(userAccount, userPassword);
    }

    @PostMapping("/register")
    public Result register(@RequestBody User user){
        return userService.register(user);
    }

    @PostMapping("/updateImg")
    public Result updateImg(Integer userId, String userImg){
        return userService.updateImg(userId, userImg);
    }
}
